import express from "express";
import mockUsers from "../data/user.js";

const router = express.Router();

// 获取用户列表
router.get("/", (req, res) => {
  console.log(req.query.name);
  res.send({
    code: 200,
    msg: "success",
    data: mockUsers,
  });
});

// 获取用户详情
router.get("/detail", (req, res) => {
  console.log(44444,req.params.id);
  res.send({
    code: 200,
    message: "success",
    data: req.query.id ? mockUsers.find((user) => user.id === req.query.id) || null : mockUsers[0],
  })
});
export default router;
